package com.smfx.yxt;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.fastjson.JSONObject;
import com.smfx.yxt.model.HkFaceGroup;
import com.smfx.yxt.service.IHkFaceGroupService;
import com.smfx.yxt.utils.HkFaceUtil;

public class FaceGroupService extends BaseTest {

	@Autowired
	private IHkFaceGroupService hkFaceGroupService;
	
	@Test
	public void addGroup() {
		//教师组、生活老师组、职员组、后勤组
		add("2012学生测试组","2012学生测试组","student");
		add("2012家长测试组","2012家长测试组","parent");
		//HkFaceUtil.addSingleFace();
	}
	
	private void add(String name, String desc, String groupType) {
		try {
			String result = HkFaceUtil.addSingleFaceGroup(name, desc);
			JSONObject jsonObject = JSONObject.parseObject(result);
			JSONObject data = jsonObject.getJSONObject("data");
			HkFaceGroup hkFaceGroup = new HkFaceGroup();
			hkFaceGroup.setIndexCode(data.getString("indexCode"));
			hkFaceGroup.setGroupType(groupType);
			hkFaceGroup.setName(name);
			hkFaceGroup.setDescription(desc);
			hkFaceGroupService.insertSelective(hkFaceGroup);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	public static void main(String[] args) {
		HkFaceUtil.addSingleFace();
	}
	
}
